package cn.intotw.rdcj.task.spiders.netty;


import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import lombok.extern.slf4j.Slf4j;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.util.concurrent.SettableListenableFuture;

import java.util.concurrent.FutureTask;

/**
 * Created by Chenxiang
 *
 * @generator: IntelliJ IDEA
 * @description:
 * @project: rdcj
 * @package: cn.intotw.rdcj.commodity.spiders.netty
 * @date: 2020年07月23日 14时52分
 */
@Slf4j
public class SpidersResultHandler extends SimpleChannelInboundHandler<String> {
    private SettableTask<String> future;
    public SpidersResultHandler(SettableTask<String> future){
        this.future=future;
    }
    @Override
    protected void channelRead0(ChannelHandlerContext channelHandlerContext, String httpContent) throws Exception {
        log.info("来了来了，他们来了{}",httpContent);
        future.setResultValue(httpContent);
    }

    @Override
    public void exceptionCaught(ChannelHandlerContext channelHandlerContext, Throwable throwable) throws Exception {
        log.error("{}异常", this.getClass().getName(), throwable);

    }
}
